import { getHomeList,getClassify,getClassDropList,getClassDetail } from "@/api/classify";

const state = {
  rankCategoryList: [],
  classift:[],
  classList:[],
  classDrop:[],
  classDetail:[]
};

const mutations = {
  updateCategoryList(state, payload) {
    state.rankCategoryList = payload;
    console.log(payload,'--------------------1232123212321');
  },
  getClassify(state,payload){
    state.classift=payload.res
    console.log(payload.res,'11111111111111111111');
    // state.classList=state.classift.filter(item=>item.id===payload.id)[0].rankList
    // console.log(state.classList,'---------');
  },
  getClassDropList(state,payload){
    console.log(payload,'2222222');
    state.classDrop=payload[0].data
  },
  getClassDetail(state,payload){
    console.log(payload,'33333333');
    state.classDetail=payload
  },
};

const actions = {
  //fl
  async getHomeList({ commit }, payload) {
    let result = await getHomeList(payload);
    commit("updateCategoryList", result.rankCategoryList);
  },
  async getClassify({ commit }, payload) {
      console.log(payload.id);
    let result = await getClassify(payload);
    let obj={
        res: result.dataList,
        id:payload.id
    }
    commit("getClassify", obj);
  },
  //世界大学
  async getClassDropList({commit},payload){
    let res = await getClassDropList(payload)
    console.log(res,'-----------1');
    commit('getClassDropList',res.dropList)
  },
  //世界大学内容
  async getClassDetail({commit},payload){
    let res = await getClassDetail(payload)
    console.log(res.rankDataList,'-----------2');
    commit('getClassDetail',res.rankDataList)
  }
};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
